// BaseCoalMineUnit.h: interface for the BaseCoalMineUnit class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_BASECOALMINEUNIT_H__B8883F87_4583_4B70_8016_08F447D69765__INCLUDED_)
#define AFX_BASECOALMINEUNIT_H__B8883F87_4583_4B70_8016_08F447D69765__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "CoalMineUnitManager.h"
#include "MonitoringUnitManager.h"

class Markup;
struct DefinitionUpdateStruct;
struct DataUpdateStruct;

struct DefinitionUpdateStructEx;
struct DataUpdateStructEx;

class BaseCoalMineUnit : public MonitoringUnitManager
{
public:
	BaseCoalMineUnit(CoalMineUnitManager * pMgr);
	virtual ~BaseCoalMineUnit();

	// Overidables
	virtual void ConvertFromXML(Markup& xml);
	virtual void ConvertToXML(Markup& xml) const;
	virtual void GetDescription(CString& strDesc) const {strDesc = GetName();}

	// Implementations
	CoalMineUnitManager * GetpManager() const {return m_pMgr;}

	long GetId() const {return m_nId;}
	void SetId(long nId) {m_nId = nId;}

	const CString& GetName() const {return m_strName;}
	void SetName(const CString& strName) {m_strName = strName;}

	const CString& GetIPAddress() const {return m_strIPAddr;}
	void SetIPAddress(const CString&  strIPAddr) {m_strIPAddr = strIPAddr;}

	bool GetbConnected() const {return m_bConnected;}
	void SetbConnected(bool bConnected) {m_bConnected = bConnected;}

	void SetTime() ;

	// UI utilities
	HTREEITEM InsertToTreeCtrl(CTreeCtrl& treectrl, HTREEITEM hItemParent) const;
	int InsertToListCtrl(CListCtrl& listctrl) const;
	int InsertToComboBox(CComboBox& combobox) const;

	void ConvertToStruct(CoalMineInfoItem * pCoalMineInfoItem) const;
	void ConvertToStruct(CoalMineInfoItemEx * pCoalMineInfoItem) const;
	void UpdateDefinition(DefinitionUpdateStruct * pDefinitionUpdateStruct);
	void UpdateData(DataUpdateStruct * pDataUpdateStruct);

	void UpdateDefinition(DefinitionUpdateStructEx * pDefinitionUpdateStruct);
	void UpdateData(DataUpdateStructEx * pDataUpdateStruct);

protected:
	CoalMineUnitManager * m_pMgr;

	long  m_nId;
	CString m_strName;
	CString m_strIPAddr;
	bool m_bConnected;
	SYSTEMTIME m_stTime;
};

#endif // !defined(AFX_BASECOALMINEUNIT_H__B8883F87_4583_4B70_8016_08F447D69765__INCLUDED_)
